--- /dev/null
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# ReMembership module for OpenERP, Other membership module for member management.
+# Copyright (C) 2012 L'Heureux Cyclage (<http://www.heureux-cyclage.org>) Ludovic CHEVALIER
+#
+# This file is a part of ReMembership
+#
+# ReMembership is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# ReMembership is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+import remembership
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
--- /dev/null
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# ReMembership module for OpenERP, Other membership module for member management.
+# Copyright (C) 2012 L'Heureux Cyclage (<http://www.heureux-cyclage.org>) Ludovic CHEVALIER
+#
+# This file is a part of ReMembership
+#
+# ReMembership is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# ReMembership is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+{
+ 'name': 'ReMembership',
+ 'version': '0.1',
+ 'category': 'Generic Modules/Association',
+ 'description': """
+ This module overload official OpenERP membership module for adding some functionnalities that could be useful.
+ """,
+ 'author': 'L\'Heureux Cyclage - LHC',
+ 'depends': ['membership'],
+ 'init_xml': [],
+ 'data': [
+ 'data/membership_sequence.xml',
+ 'view/partner.xml',
+ ],
+ 'update_xml': [],
+ 'demo_xml': [],
+ 'test': [],
+ 'installable': True,
+ 'active': False,
+}
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
--- /dev/null
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Remembership module for OpenERP, Overload membership module
+# Copyright (C) 2012 L'Heureux Cyclage (<http://www.heureux-cyclage.org>) Ludovic CHEVALIER
+#
+# This file is a part of Remembership
+#
+# Remembership is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Remembership is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from osv import osv
+from osv import fields
+
+class Partner(osv.osv):
+ _inherit = 'res.partner'
+
+ _columns = {
+ 'member_ident': fields.char('Member identifier', size=64, readonly=True),
+ }
+
+ def create_membership_invoice(self, cr, uid, ids, product_id=None, datas=None, context=None):
+ """ Create Customer Invoice of Membership for partners.
+ @param datas: datas has dictionary value which consist Id of Membership product and Cost Amount of Membership.
+ datas = {'membership_product_id': None, 'amount': None}
+ """
+ invoice_obj = self.pool.get('account.invoice')
+ invoice_line_obj = self.pool.get('account.invoice.line')
+ invoice_tax_obj = self.pool.get('account.invoice.tax')
+ product_id = product_id or datas.get('membership_product_id', False)
+ amount = datas.get('amount', 0.0)
+ invoice_list = []
+ if type(ids) in (int, long,):
+ ids = [ids]
+ for partner in self.browse(cr, uid, ids, context=context):
+ account_id = partner.property_account_receivable and partner.property_account_receivable.id or False
+ fpos_id = partner.property_account_position and partner.property_account_position.id or False
+ addr = self.address_get(cr, uid, [partner.id], ['invoice'])
+ if partner.free_member:
+ raise osv.except_osv(_('Error !'),
+ _("Partner is a free Member."))
+ if not addr.get('invoice', False):
+ raise osv.except_osv(_('Error !'),
+ _("Partner doesn't have an address to make the invoice."))
+ quantity = 1
+ line_value = {
+ 'product_id': product_id,
+ }
+
+ line_dict = invoice_line_obj.product_id_change(cr, uid, {},
+ product_id, False, quantity, '', 'out_invoice', partner.id, fpos_id, price_unit=amount, context=context)
+ line_value.update(line_dict['value'])
+ line_value['price_unit'] = amount
+ if line_value.get('invoice_line_tax_id', False):
+ tax_tab = [(6, 0, line_value['invoice_line_tax_id'])]
+ line_value['invoice_line_tax_id'] = tax_tab
+
+ invoice_id = invoice_obj.create(cr, uid, {
+ 'partner_id': partner.id,
+ 'address_invoice_id': addr.get('invoice', False),
+ 'account_id': account_id,
+ 'fiscal_position': fpos_id or False
+ }, context=context)
+ line_value['invoice_id'] = invoice_id
+ invoice_line_id = invoice_line_obj.create(cr, uid, line_value, context=context)
+ invoice_obj.write(cr, uid, invoice_id, {'invoice_line': [(6, 0, [invoice_line_id])]}, context=context)
+ invoice_list.append(invoice_id)
+ if line_value['invoice_line_tax_id']:
+ tax_value = invoice_tax_obj.compute(cr, uid, invoice_id).values()
+ for tax in tax_value:
+ invoice_tax_obj.create(cr, uid, tax, context=context)
+ if partner.member_ident:
+ mbr_id = partner.member_ident
+ else:
+ mbr_id = self.pool.get('ir.sequence').get(cr, uid, 'member_ident')
+ #recompute the membership_state of those partners
+ self.pool.get('res.partner').write(cr, uid, ids, {'member_ident': mbr_id})
+ return invoice_list
+
+Partner()
+
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: